<!doctype html>
<html lang="en">
<head>
    @include('Admin.header')
    <meta charset="UTF-8">
    <title>后台登录</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        .form-input{
            width:90%;
        }
        .layui-form-item{
            display:flex;
        }

    </style>
</head>
<body>
<div class="login-logo"><h1>后台登录</h1></div>
<div class="login-box">
    <form class="layui-form layui-form-pane" id="form" action="">
        <h3>登录你的帐号</h3>
        <label class="login-title" for="account">帐号</label>
        <div class="layui-form-item" >
            <label class="layui-form-label login-form" style="width:20%"><i class="iconfont">&#xe6b8;</i></label>
            <div class="form-input">
                <input type="text" id="account" name="account" lay-verify="required" placeholder="请输入你的帐号" autocomplete="off" class="layui-input">
            </div>
        </div>
        <label class="login-title" for="password">密码</label>
        <div class="layui-form-item">
            <label class="layui-form-label login-form" style="width:20%"><i class="iconfont">&#xe82b;</i></label>
            <div class="form-input">
                <input type="password" id="password"  name="password" lay-verify="required" placeholder="请输入你的密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="form-actions">
            {{ csrf_field() }}
            <button class="btn btn-warning pull-right" lay-submit lay-filter="login"  type="submit" style="width:50%">登录</button>
            <div class="forgot"></div>
        </div>
    </form>
</div>

<script>
    $(function  () {
        layui.use('form', function(){
            var form = layui.form;
            //监听提交
            form.on('submit(login)', function(data){
                $.ajax({
                    dataType:'json',
                    type: 'post',
                    url: '{{url("Admin/Login/login/do")}}',
                    data: $('#form').serialize(),
                    success: function(data){
                        if(1 == data){
                            layer.msg('登录成功!', {
                                icon: 1,
                                time: 2000 //2秒关闭（如果不配置，默认是3秒）
                            }, function(){
                                parent.layer.closeAll();
                                window.location.href='{{url("Admin/Index/index")}}'
                            });
                        }else{
                            layer.msg('登录失败!');
                        }
                    }
                });
                return false;
            });
        });
    })

</script>
<script>

</script>
</body>
</html>